/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package database;

import java.io.InputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
 *
 * @author Dhruv
 */
public class Database {
    private static String driver;
    private static String url;
    private static String username;
    private static String password;
    /** Creates a new instance of DBOperation */

    public Database() {
    }

    public static Connection getConnection(){
        Connection conn = null;
        Properties props = new Properties();
        //load the database property file
        

        //read database properties
        driver = "com.mysql.jdbc.Driver";
        url = "jdbc:mysql://localhost:3306/Customer";
        username = "root";
        password = "warchief1@";
        //get the database conncection
        try {
            Class.forName(driver);
            conn = DriverManager.getConnection(url, username, password);
        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }

        return conn;
    }

    //close the connection
    public static void closeDatabase(Connection conn) {
        try {
            conn.close();
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }

}
